\section{cos --- Cosine}
\label{fn:cos}
\index{cos()}
\index{cosine}
\begin{rail}
Cosine : 'cos' '(' ( Scalar | Matrix ) ')' ;
\end{rail}

\verb+cos+ calculates the cosine of the argument, which is taken as being
specified in radians.  If the argument is a matrix, the \verb+cos+ operation
is performed element by element.  If the argument is complex, given by $z$,
then the result is:

\[ \cos(\Re(z)) \cosh(\Im(z)) -j \sin(\Re(z)) \sinh(\Im(z)) \]

\paragraph{Example}
\index{example of cos()}
\index{cos()!example}
\begin{verbatim}
> cos(0)
        1
> cos(pi/2)
 6.12e-17
> cos(pi)
       -1
> cos(pi/4)
    0.707
> cos(1+1j)
    0.834 - 0.989i
> a = rand(2,5)*pi
 a =
     3.14       2.03      0.116       2.09      0.641  
     3.06       1.05      0.508      0.266      0.526  
> cos(a)
       -1     -0.447      0.993     -0.494      0.801  
   -0.997      0.501      0.874      0.965      0.865
\end{verbatim}

See also: Page~\pageref{fn:acos} \verb+acos()+,
Page~\pageref{fn:cosh} \verb+cosh()+,
Page~\pageref{fn:sin} \verb+sin()+,
Page~\pageref{fn:tan} \verb+tan()+.

\newpage




